package com.pic.mgt.monitor.parser;

import com.pic.mgt.monitor.WrongUnitFormatException;


public final class businessTypeParser extends FormatParser {
	private int businessTypeAtChar;

	public businessTypeParser() {
		
	}
	
	@Override
	public String parse(Object _confirmationFilename)
						throws WrongUnitFormatException {
		// 確認是否為 String 型態
		// throws WrongUnitFormatException
		super.checkObjectType(_confirmationFilename, String.class);
		
		String confirmationFilename = (String)_confirmationFilename;
		
		String type = null;
		try {
			// throws StringIndexOutOfBoundsException
			type = String.valueOf(confirmationFilename
						.charAt(businessTypeAtChar - 1));
		} catch (StringIndexOutOfBoundsException e) {			
			e.printStackTrace();
			throw new WrongUnitFormatException(
					"Confirmation file format is invalid.", e);
		}		
		return type;
	}

	public void setBusinessTypeAtChar(int businessTypeAtChar) {
		this.businessTypeAtChar = businessTypeAtChar;
	}
}
